/*
 * @Description  : 
 * @Author       : zhao
 * @Date         : 2022-07-06 13:48:10
 * @LastEditors  : zhao
 * @LastEditTime : 2023-02-01 16:06:34
 */
/*
 * @Description:获取档案文件信息
 * @Version: 2.0
 * @Author: zhao
 * @Date: 2022-06-17 09:27:12
 * @LastEditors: zhao
 * @LastEditTime: 2022-07-07 09:49:20
 */
import {
    GeodatainfoArchive,
    GetArchive,
    GetSnToFile,
    GetSnToFilePrimary,
    GetPhysicalData,
    GetHomeNumber,
    GetCategory,
    GetDivision,
    GetNoticeList,
    GetNoticeBS,
    AddbrowseNumber
} from '@/api/home'

import { MessageBox, Message } from 'element-ui'
const state = {

}

const mutations = {


}

const actions = {
    //首页 - 地质资料目录中心
    getGeodatainfoArchive({ commit }, data) {

        return new Promise((resolve, reject) => {
            GeodatainfoArchive(data).then(res => {
                resolve(res)
            }).catch(error => {

                reject(error)
            })
        })
    },
    //搜索
    getArchive({ commit }, data) {

        return new Promise((resolve, reject) => {
            GetArchive(data).then(res => {
                resolve(res)
            }).catch(error => {

                reject(error)
            })
        })
    },
    //档案详情
    getSnToFile({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetSnToFile(data).then(res => {
                if (res.code == 200) {

                    resolve(res)
                } else {
                    Message.errpr(res.msg || "获取成果资料失败")
                }
            }).catch(error => {

                reject(error)
            })
        })
    },
    //获取数字
    getHomeNumber({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetHomeNumber(data).then(res => {
                resolve(res)
            }).catch(error => {

                reject(error)
            })
        })
    },
    //首页，左侧导航的地质资料类别
    getCategory({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetCategory(data).then(res => {
                resolve(res)
            }).catch(error => {

                reject(error)
            })
        })
    },
    //获取区划
    getDivision({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetDivision(data).then(res => {
                resolve(res)
            }).catch(error => {

                reject(error)
            })
        })
    },
    //获取公告
    getNoticeList({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetNoticeList(data).then(res => {
                if (res.code == 200) {

                    resolve(res)
                } else {
                    Message.errpr(res.msg || "获取公告失败")
                }
            }).catch(error => {

                reject(error)
            })
        })
    },
    //获取公告 -详情
    GetNoticeBS({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetNoticeBS(data).then(res => {
                if (res.code == 200) {

                    resolve(res)
                } else {
                    Message.errpr(res.msg || "获取公告详情失败")
                }
            }).catch(error => {

                reject(error)
            })
        })
    },
    //实物资料
    getPhysicalData({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetPhysicalData(data).then(res => {
                if (res.code == 200) {

                    resolve(res)
                } else {
                    Message.errpr(res.msg || "实物资料失败")
                }
            }).catch(error => {

                reject(error)
            })
        })
    },
    //添加浏览量
    AddbrowseNumber({ commit }, data) {
        return new Promise((resolve, reject) => {
            AddbrowseNumber(data).then(res => {
                if (res.code == 200) {

                    resolve(res)
                } else {
                    Message.errpr(res.msg || "添加浏览量失败")
                }
            }).catch(error => {

                reject(error)
            })
        })
    },
    //通过案卷号获取文件列表--原始资料
    GetSnToFilePrimary({ commit }, data) {
        return new Promise((resolve, reject) => {
            GetSnToFilePrimary(data).then(res => {
                if (res.code == 200) {

                    resolve(res)
                } else {
                    Message.errpr(res.msg || "获取原始资料失败")
                }
            }).catch(error => {

                reject(error)
            })
        })
    },
}
const getters = {

}
export default {
    namespaced: true,
    state,
    mutations,
    getters,
    actions
}
